﻿Public Class FormatMainForm
    Implements IFormatMainForm

    Public Sub RefreshLeft(ByVal dt As System.Data.DataTable, ByVal dv As System.Windows.Forms.DataGridView) Implements IListenDb.IFormatMainForm.RefreshLeft

        If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
            dv.DataSource = dt
            dv.Columns("快照时间").Visible = False

            For index As Integer = 0 To dv.Columns.Count - 1
                dv.Columns(index).SortMode = Windows.Forms.DataGridViewColumnSortMode.NotSortable
            Next
        End If

    End Sub

    Public Sub RefreshRight(ByVal dt As System.Data.DataTable, ByVal dv As System.Windows.Forms.DataGridView) Implements IListenDb.IFormatMainForm.RefreshRight

        dv.DataSource = dt
        dv.Tag = dv.DataSource

        'dv.Columns("编号").Visible = False
        dv.Columns("更新表名称").Visible = False
        dv.Columns("实际表名称").HeaderText = "更新表名称"
        dv.Columns("更新类型").HeaderText = ""
        dv.Columns("编号").HeaderText = ""

        dv.Columns("快照时间").Visible = False
        dv.Columns("更新表时间").Visible = False
        dv.Columns("快照时间").Visible = False

        For index As Integer = 0 To dv.Columns.Count - 1
            dv.Columns(index).SortMode = Windows.Forms.DataGridViewColumnSortMode.NotSortable
        Next

    End Sub

    Public Sub InitTitle(ByRef title As String) Implements IListenDb.IFormatMainForm.InitTitle

        Dim constring As New util.Util.ConUtil(CommonConUtil.连接字符串)

        Dim strSql As New System.Text.StringBuilder
        strSql.AppendLine(" SELECT Company.CompanyName  FROM SMILEV7SYS.dbo.DBConnection")
        strSql.AppendLine("   LEFT JOIN SMILEV7SYS.dbo.Company")
        strSql.AppendLine("     ON DBConnectionID=DefaultDBConnectionID")
        strSql.AppendLine("  WHERE DBConnection.SchemaName='" & constring.DataBase & "'")

        Dim dt As DataTable = CommonConUtil.GetTable(strSql.ToString)
        If dt.Rows.Count > 0 Then
            title = "监听数据库 - 会社(" & CStr(dt.Rows(0)(0)) & ")"
        End If

    End Sub

End Class
